<nav class="tab-bar">
  <section class="tab-bar-section">
    <h1>Results
      <span class="small-heading">
        <%= page_entries_info @results %>
        <% if @results.total_count != @total_result_count %><b>(<%= @total_result_count - @results.total_count %>
            results  filtered)</b><% end %>
      </span>
    </h1>
  </section>
  <section class="pagination">
    <%= paginate @results, :method=>:post, :params=> nil, :outer_window => 3, :window=>1, :remote=> (defined? remote)? remote : false %>
  </section>
  <section class="buttons button-bar">
    <ul class="button-group">
      <li><%= link_to "", results_path(:view=>"list"), :class=>"view-button fi-list-bullet" %></li>
      <li><%= link_to "", results_path(:view=>"tiles"), :class=>"view-button fi-thumbnails" %></li>
    </ul>
  </section>
</nav>
<div class="panel" style="display:none" id="update_all_from_page_header">
  <p>All
    <%= @results.count %>
    results on this page selected.
    <%= link_to "Select all #{@results.total_count} results that match this filter", "#", :id=>"update_all_from_query_link" %></p>
</div>
<div class="panel" style="display:none" id="update_all_from_query_header">
  <p>All
    <%= @results.total_count %>
    results in this search selected.
    <%= link_to "Clear selection", "#", :id=>"clear_selection" %></p>
</div>

<% if @view == "tiles" %>
  <%= render 'results_tiles' %>
<% else %>
  <%= render 'results_table' %>
<% end %>


<%= content_for :sidebar do %>
  <div class="sidebar" id="result_action_panel" style="display:none">
    <nav class="tab-bar">
      <section class="tab-bar-section">
        <h1>Actions
        </h1>
      </section>
    </nav>
    <section class="panel sidepanel">
      <%= form_tag update_multiple_results_path, method: :post, :id=>"update_results_form" do %>
        <%= label_tag do %>Status
          <%= select_tag :status_id, options_from_collection_for_select(Status.all, "id", "name"), {:prompt => 'Please select', class: 'select2'} %>
        <% end %>
        <%= label_tag do %>Tags
          <%= hidden_field_tag "tags", "", {class: "remote_select2", "data-multiple"=>true, "data-id-attribute"=>"name_value" , "data-parse-initial"=>"true", "data-create-new"=>"true", "data-object"=>"tags", "data-attribute"=>"name_value" , "data-path"=>tags_path} %>
        
        <% end %>  
        <%= label_tag "Remove" do %>
        <%= check_box_tag :remove_tags, '1', false %> Remove
        <% end %>

  
        <%= label_tag do %>Assignee
          <%= select_tag :assignee_id, options_from_collection_for_select(User.all, :id, :email), {:prompt => 'Please select', class: "select2"} %>
        <% end %>
        <%= hidden_field_tag :q, params[:q].to_json %>
        <%= hidden_field_tag :update_all_from_query, false, {:id=>'update_all_from_query'} %>
        <% button_options = ["Update", "Update and Generate Screenshot", "Update and Force Generate Screenshot"] %>
                
        
        <%= split_button  button_options, :button_class=>'small', :link_class=>'update_multiple_button' %>
        <% if(can? :destroy, Result) %>
          <%= submit_tag "Delete Results", class: "button alert small update_multiple_button", data: { confirm: "Are you sure you want to delete the selected results?" } %>
        <% end %>
      <% end %>
    </section>
  </div>
<% end %>
<%= paginate @results, :method=>:post, :params=> nil, :outer_window => 3, :window=>1, :remote=> (defined? remote)? remote : false %>
<br />
<%= link_to 'New Result', new_result_path, class: "button" %>
<%= link_to "Bulk Add Results", "#", :class=>"button", data:{"reveal-id"=>"bulk_add_form"} %>
<div id="bulk_add_form" class="reveal-modal custom-modal" data-reveal>
  <header class="popup-header">
    <div class="row">
      <div class="large-12 columns">
        <h4>Bulk Add Results</h4>
      </div>
    </div>
  </header>
  <div class="row">
    <div class="large-12 columns">
      <%= form_tag bulk_add_results_path do |f| %>
        <%= text_area_tag :results %> 
        <%= label_tag do %>Tags
          <%= hidden_field_tag "tags", "", {class: "remote_select2", "data-multiple"=>true, "data-id-attribute"=>"name_value" , "data-parse-initial"=>"true", "data-create-new"=>"true", "data-object"=>"tags", "data-attribute"=>"name_value" , "data-path"=>tags_path} %>
        
        <% end %>  
        <%= submit_tag "Submit", :class=>"button tiny preload" %>
        <%= button_tag "Cancel", :type=>:button, :class=>"button secondary tiny close-modal" %>
      <% end %>
    </div>
  </div>
</div>



<%= content_for :sidebar do %>
  <div class="sidebar">
    <nav class="tab-bar">
      <section class="tab-bar-section">
        <h1>Filter
        </h1>
      </section>
    </nav>
    <section class="panel sidepanel">
      <%= search_form_for @q, :url=>search_results_path, :method=>:post, :authenticity_token => false, id:"search_form"  do |f| %>
        <%= render partial: 'search_fields', locals: {f: f}%>
        <%= f.submit class: "button small" %>
        <%= f.submit "Clear Search", class: "button secondary small" %>
        <%= f.submit "Save", class: "button secondary small" %>
        <%#= f.button "Reset", type: :reset, class:"secondary" %>
      <% end %>
    </section>
  </div>
<% end %>
